package com.pension.servlet;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.pension.model.dao.MemberDao;
import com.pension.model.dto.Member;

@WebServlet("/member/view.action")
public class MemberViewServlet extends HttpServlet {
	
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
		throws ServletException, IOException {
		
		String id = req.getParameter("memberid");
		MemberDao dao = new MemberDao();
		Member member = dao.getMemberById(id);
		
		req.setAttribute("member", member);
		
		RequestDispatcher dispatcher = 
				req.getRequestDispatcher("/WEB-INF/views/member/view.jsp");

		dispatcher.forward(req, resp);
		
	}
	
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) 
		throws ServletException ,IOException {
		
		req.setCharacterEncoding("utf-8");
		
		doGet(req, resp);
	};

}








